package com.sky.mapper;

import com.sky.annotation.AutoFill;
import com.sky.dto.UserLoginDTO;
import com.sky.entity.User;
import com.sky.enumeration.OperationType;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDateTime;

@Mapper
public interface UserMapper {
    @Select("SELECT * FROM user WHERE username = #{username} AND password = #{password}")
    User selectByOpenId(UserLoginDTO userLoginDTO);

    void insert(User user);

    @Select("SELECT * FROM user WHERE id = #{userId}")
    User selectById (Long userId);

    Integer countNewUser(LocalDateTime beginTime, LocalDateTime endTime);

    Double countTotalUser(LocalDateTime endTime);

    @Select("SELECT COUNT(*) FROM user WHERE username = #{username}")
    Integer selectUserName(UserLoginDTO userLoginDTO);

    @Insert("INSERT INTO user (username,password,create_time) VALUES(#{username},#{password},#{createTime})")
    void regist(UserLoginDTO userLoginDTO);
}
